#include "FileCtrl.h"

FileCtrl::FileCtrl(){

}
QString FileCtrl::readLineOfNameFile(std::string filepath,UINT32 lineNum){
    QString qfilePath = QString::fromStdString(filepath);
    if(!QFile::exists(qfilePath)){
        QDEBUG_FILE_FUNC<<"file is not exists : "<<qfilePath ;
        return QString("");
    }
    QFile file(qfilePath);
    if(!file.open(QIODevice::ReadOnly|QIODevice::Text)){
        QDEBUG_FILE_FUNC<<"can't open file : "<<qfilePath ;
        return QString("");
    }

    //逐行读取文件内容
    QTextStream in(&file);
    UINT32 index = 0;
    while(!in.atEnd()){
        QString line = in.readLine();
        if(index == lineNum){
            return line;
        }
        index++;
    }
    return QString("");
}
